package com.itcc.dao;

import com.itcc.domain.Customer;
import com.itcc.domain.CustomerInfo;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

@Mapper
@Transactional
public interface CustomerDao {

//    ctm_name, ctm_unit, ctm_post, ctm_birthday, ctm_sex, ctm_tel

    @Select("select * from ctm_customer")
    public List<Customer> selectCustomer();

    //查询密码
    @Select("select ctm_tel from ctm_customer where ctm_name=#{ctm_name}")
    public String selectTelByName(@Param("ctm_name") String ctm_name);

    //注册信息入库
    @Insert("insert into ctm_customer(ctm_name, ctm_unit, ctm_post, ctm_birthday, ctm_sex, ctm_tel)" +
            " values (#{ctm_name}, #{ctm_unit}, #{ctm_post}, #{ctm_birthday}, #{ctm_sex}, #{ctm_tel})")
    public boolean inertCustomer(Customer customer);

    @Insert("insert into customer_info(username, profile, docx) values (#{username}, #{profile}, #{docx})")
    public boolean insertCustomer_info(CustomerInfo customerInfo);

    @Select("select profile from customer_info where username = #{username}")
    public String selectProfile(@Param("username") String username);

}
